import QtQuick 2.6

import "../Base/Config"
import "../Base/Code"

import FunctionalItem 1.0
import Cpp.Request 1.0 as Request

LoginForm {
    color: Color.main

    touristLoginButton.onClicked: {
        login.touristLogin()
    }

    loginButton.onClicked: {
        login.login(usernameInput.text, passwordInput.text)
    }

    loginFailedIcon.visible: login.status === RequestCode.failed //|| login.status === RequestCode.error

    Component.onCompleted: {
        usernameInput.text = "18807734862"
        passwordInput.text = "0403"
    }

    FocusSwitch {
        id: focusSwitch
        sequence: [usernameInput, passwordInput]
        accept: loginButton
    }

    Loader {
        id:registerLoader
        parent: mainRoot
        anchors.fill: parent
        Connections {
            target: registerLoader.item
            onLoginClicked: {
                registerLoader.source = ""
            }
        }
    }
    Request.Login {
        id: login
    }
}
